home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: 1998
- // Author: DRB & APP
- //
-
- // IF YOU ARE CHANGING THE NAMES OF THESE VARIABLES YOU
- // MUST ALSO CHANGE THEIR NAMES IN OTHER MEL FILES WHERE THEY
- // ARE REFERENCED! (ie. setPresetTmpIcon.mel) APP 17mar99
- global string $gTmpPaintPresetShelveButton;
- global string $gTmpPaintPresetLabelField;
- global string $gTmpPaintPresetOverlayField;
- global int $gBrushPresetWinUpdateJob;
- global string $gSaveBrushToShelf;
- global string $gTmpVisorDirField;
- global int $gBrushCount = 1;
-
- proc string makeNTPath( string $path ) {
- string $retPath = `substitute "/" $path "\\\\"`;
- string $c = `match "/" $retPath `;
- while ( $c != "" ) {
- $retPath = `substitute "/" $retPath "\\\\"`;
- $c = `match "/" $retPath `;
- }
- return $retPath;
- }
-
- proc string getPfxImageLocation( string $imageName )
- {
- // We Added this routine because the following line
- // failed to find images in the brushImages directory.-DB
-
- string $fullPath = `file -q -loc $imageName`;
- if( $fullPath == "unknown" ){
- string $visorBase = `getenv "MAYA_LOCATION"`;
- if ($visorBase != "") {
- $fullPath = `file -q -loc ($visorBase + "/brushImages/" + $imageName)`;
- }
- if( $fullPath == "unknown" ){
- string $iconDir = `internalVar -userBitmapsDir`;
- if( $iconDir != "" ){
- string $brushImagePath = ($iconDir + "brushImages/");
- $brushImagePath = substitute( "/icons", $brushImagePath, "");
- $fullPath = `file -q -loc ($brushImagePath + $imageName)`;
- }
- }
- }
- return $fullPath;
- }
-
- //
- // This routine makes use of many system dependent utilities like copy, mkdir, delete, etc.
- // It really should make use of as many MEL commands to do this as possible instead of the
- // conditional operating system dependent code. APP 11may01
- global proc saveBrushPreset()
- {
- // IF YOU ARE CHANGING THE NAMES OF THESE VARIABLES YOU
- // MUST ALSO CHANGE THEIR NAMES IN OTHER MEL FILES WHERE THEY
- // ARE REFERENCED! (ie. setPresetTmpIcon.mel) APP 17mar99
- global string $gTmpPaintPresetShelveButton;
- global string $gTmpPaintPresetLabelField;
- global string $gTmpPaintPresetOverlayField;
- global string $gShelfTopLevel;
- global string $gSaveBrushToShelf;
- global string $gTmpVisorDirField;
- global int $gBrushCount;
- int $i;
-
- // gSelectDir is a flag to identify whether the
- // directory is selected thro' text field or fileBrowser
-
- global int $gSelectDir;
- global string $gVisorSelectedDirectory;
- global string $gLastPresetDir;
-
- $shelfLayout = $gShelfTopLevel;
-
- if (`radioButtonGrp -q -sl $gSaveBrushToShelf` != 1 && `about -evalVersion`){
- // Because fopen and fprint are disabled in PLE,
- // saveBrushPreset to Visor is not supported.
- warning ("saveBrushPreset to Visor is not supported in Maya PLE.");
- return;
- }
-
- if (`tabLayout -exists $shelfLayout` == 0)
- {
- error ("saveBrushPreset: Error, can't find current shelf: " + $shelfLayout );
- return;
- }
-
- string $brushName = `getDefaultBrush`;
-
- if (`nodeType $brushName` != "brush" )
- {
- error ("saveBrushPreset: Error, can't find template brush: " + $brushName );
- return;
- }
-
- string $label =
- `textFieldGrp -q -tx $gTmpPaintPresetLabelField`;
- string $overlay =
- `textFieldGrp -q -tx $gTmpPaintPresetOverlayField`;
-
- if( $label == ("brush" + $gBrushCount) )
- $gBrushCount++;
-
- string $tmpIcon = `shelfButton -q -i1 $gTmpPaintPresetShelveButton`;
- string $iconName = "userPaint.xpm";
- string $tmpIconPath;
-
- string $brushImagePath;
-
- string $iconDir = `internalVar -userBitmapsDir`;
- string $prefDir = `internalVar -userPrefDir`;
-
- if (`radioButtonGrp -q -sl $gSaveBrushToShelf` == 1) {
- // The user wishes to save this preset to the shelf. (Not the visor).
-
- // Set the brushImage directory path appropriately.
- $brushImagePath = ($iconDir + "brushImages/");
- $brushImagePath = substitute( "/icons", $brushImagePath, "");
-
- if( $tmpIcon != $iconName )
- {
- $iconName = $label;
- string $iconPathName = ($iconDir + $iconName);
- if(`about -mac`)
- $iconPathName += ".iff"; // Mac gives the grabbe image as iff and uses it as it is.
- else
- $iconPathName += ".xpm";
-
- if( `file -q -ex $iconPathName` )
- {
- // So, like, if there are more than 100 presets of the same name already,
- // we just keep overwriting the same icon. Just so you know. APP
- for( $i = 0; $i < 100; $i++ )
- {
- string $newName = ($iconName + $i);
- $iconPathName = ($iconDir + $newName);
- if(`about -mac`)
- $iconPathName += ".iff";
- else
- $iconPathName += ".xpm";
-
- if( `file -q -ex $iconPathName` == 0 )
- {
- $iconName = $newName;
- break;
- }
- }
- }
- $tmpIconPath = ($iconDir + $tmpIcon);
- if ( `about -nt` ) {
- // Even though the path may have been entered with '\', Maya has
- // replaced those with '/' which makes the following 'copy' not work.
- // So, we substitute bits of the string. APP 07apr99
-
- string $NTIconPath = `substitute "/" $tmpIconPath "\\\\"`;
- string $c = `match "/" $NTIconPath `;
- while ( $c != "" ) {
- $NTIconPath = `substitute "/" $NTIconPath "\\\\"`;
- $c = `match "/" $NTIconPath `;
- }
-
- string $NTIconPathName = `substitute "/" $iconPathName "\\\\"`;
- $c = `match "/" $NTIconPathName `;
- while ( $c != "" ) {
- $NTIconPathName = `substitute "/" $NTIconPathName "\\\\"`;
- $c = `match "/" $NTIconPathName `;
- }
-
- sysFile -copy $NTIconPathName $NTIconPath;
- }
- else if (`about -irix` || `about -linux` || `about -mac`) {
- sysFile -copy $iconPathName $tmpIconPath;
- } else {
- warning("Unknown and unimplemented operating system in saveBrushToShelf.mel");
- }
-
- }
- string $currentShelf = `tabLayout -q -st $shelfLayout`;
- string $buttonParent = ($shelfLayout + "|" + $currentShelf);
- setParent $buttonParent;
-
- // Create a command for this button
- string $shelfCommand = `createBrushPresetScript $brushName`;
- $shelfCommand = $shelfCommand + "rename (getDefaultBrush()) " + $label +";";
-
- // Create a button on this shelf
- string $bName = `shelfButton -parent $buttonParent`;
- if(`about -mac`){
- if(!gmatch( $iconName, "*.iff") ) {
- $iconName += ".iff";
- }
- }else{
- if ( !gmatch( $iconName, "*.xpm") )
- // If it does not have the .xpm extension, add it.
- $iconName += ".xpm";
- }
- shelfButton
- -e
- -command $shelfCommand
- -label $label
- -iol $overlay
- -st "iconAndTextHorizontal"
- -width `shelfLayout -q -cellWidth $currentShelf`
- -height `shelfLayout -q -cellHeight $currentShelf`
- -i1 $iconName
- $bName;
- }
- else {
- // The user wishes that this brush be saved to Visor.
- string $visorDir = `textFieldGrp -q -text $gTmpVisorDirField`;
- // MAYA_LOCATION must be writable by the user for them to be able to save a preset to Visor.
- string $visorBase = `getenv "MAYA_LOCATION"`;
- if ($visorBase != "") {
-
- // Set the brushImage directory path appropriately.
- $brushImagePath = ($visorBase + "/brushImages/");
-
- string $brushDir;
-
- if($gSelectDir)
- {
- // Directory is selected through fileBrowser.
-
- if ($visorDir != "")
- {
- $brushDir = ($visorDir +"/");
- string $visorEd = "visorPanel1VisorEd";
- }
- else
- {
- $brushDir = ($prefDir + "brushes/");
- }
- }
- else
- {
- // Directory name is entered in the Text Field.
- if ($visorDir != "") {
- $brushDir = ($prefDir + "brushes/" + $visorDir +"/");
- //$brushDir = ($visorBase + "/brushes/" + $visorDir + "/");
- //If the $visorDir directory does not exist, create on and add to visor.
- string $visorEd = "visorPanel1VisorEd";
- }
- else {
- $brushDir = ($prefDir + "brushes/");
- //$brushDir = ($visorBase + "/brushes/");
- }
- }
-
- // if $brushDir doesn't exists, create it.
- if(`file -q -ex $brushDir` == 0)
- {
- sysFile -makeDir $brushDir;
- }
-
- //if(`about -mac`) // deliberately NT is avoided here.
- // $brushDir = unconvert($brushDir);
- string $brushFile = ($label + ".mel");
- string $iconFile;
- if(`about -mac`)
- $iconFile = ($brushFile + ".iff");
- else
- $iconFile = ($brushFile + ".icon");
-
- // Create a command for this button
- string $shelfCommand = `createBrushPresetScript $brushName`;
- $shelfCommand = $shelfCommand + "rename (getDefaultBrush()) " + $label +";";
-
- // Save this command to a file.
- string $brushPathName = ($brushDir + $brushFile);
-
- if( `file -q -ex $brushPathName` )
- {
- string $result;
- $result = `confirmDialog -m ($brushPathName +" already exists. \n Do you want to replace it?")
- -ma center -b "Yes" -b "No" -db "No" -title ("Save (" + $brushPathName + ")")`;
-
- if($result == "No")
- {
- return;
- }
-
- string $newName = ($label + ".mel");
- $brushPathName = ($brushDir + $newName);
-
- if( `file -q -ex $brushPathName` == 0 )
- {
- $brushFile = $newName;
- if(`about -mac`)
- $iconFile = ($newName + ".iff");
- else
- $iconFile = ($newName + ".icon");
- }
- }
-
- // fopen seems to open it for write + append by default, so specify "w" to stop the append.
- int $fileId = `fopen $brushPathName "w"`;
- if ($fileId == 0) {
- error ("saveBrushPreset: Error, can't write to Visor file: " + $brushPathName );
- }
- else {
- fprint $fileId $shelfCommand;
- fclose $fileId;
- }
-
- // Save the icon to the brushDir.
- string $iconPathName = ($brushDir + $iconFile);
-
- $tmpIconPath = ($iconDir + $tmpIcon);
- if(`about -mac`) // for Mac check for .iff and others .xpm.
- {
- if ( gmatch( $tmpIconPath, "*.iff") ) {
- // If it does have the .iff extension, delete it.
- $tmpIconPath = substitute (".iff", $tmpIconPath , "");
- }
- } else {
- if ( gmatch( $tmpIconPath, "*.xpm") ) {
- // If it does have the .xpm extension, delete it.
- $tmpIconPath = substitute (".xpm", $tmpIconPath , "");
- }
- }
- if(`about -mac`)
- $tmpIconPath += ".iff";
- else
- $tmpIconPath += ".rgb";
- if ( `about -nt` ) {
- // Even though the path may have been entered with '\', Maya has
- // replaced those with '/' which makes the following 'copy' not work.
- // So, we substitute bits of the string. APP 07apr99
-
- string $NTIconPath = makeNTPath( $tmpIconPath );
-
- string $NTIconPathName = makeNTPath( $iconPathName );
-
- sysFile -copy $NTIconPathName $NTIconPath;
- }
- else if (`about -irix` || `about -linux` || `about -mac`) {
- sysFile -copy $iconPathName $tmpIconPath;
- } else {
- warning("Unknown and unimplemented operating system in saveBrushToShelf.mel");
- }
- }
- }
-
- // Now we want to look at the template brush and find any file textures which are
- // applied and copy them to the maya/#.#/prefs/icons directory.
- string $imageName = `getAttr ($brushName + ".imageName")`;
- int $useFrameExt = `getAttr ($brushName + ".useFrameExtension")`;
- string $leafImage = `getAttr ($brushName + ".leafImage")`;
- string $flowerImage = `getAttr ($brushName + ".flowerImage")`;
- string $tbip = "";
-
- if ( `about -nt` ) {
- $tbip = $brushImagePath;
- $brushImagePath = makeNTPath( $brushImagePath );
- }
- if ($imageName != "" || $leafImage != "" || $flowerImage != "") {
- // Check to see if the brushImages/ directory exists.
- if ( !`file -q -ex $brushImagePath` ) {
- // If not, create it. There are no checks to see if this succeeds or fails
- // because the system command does not return the status of commands, only their
- // output. Bug logged to correct this.
- sysFile -makeDir $brushImagePath;
- if ( !`file -q -ex $brushImagePath` ) {
- warning("Unable to create the directory : " + $brushImagePath );
- }
- }
- }
-
- if ( `file -q -ex $brushImagePath` ) {
- if ( $imageName != "" ) {
- string $buffer[];
- $numTokens = `tokenize $imageName "/" $buffer`;
- $imageName = $buffer[$numTokens-1];
-
- if ($useFrameExt) {
- // We will have to copy a number of files. Look for all files with the common root and
- // an extension and copy them.
- int $ext = `getAttr($brushName + ".frameExtension")`;
- string $buffer[];
- int $numTokens = tokenize( $imageName, ".", $buffer );
-
- // Try to find if there is a numerical component to the input string.
- // If so, assume it is the fame number and extract it from the image name.
- if ($numTokens > 1) {
- int $i = 1;
- $imageName = $buffer[0];
- while ( $i < $numTokens ) {
- if (
- substring($buffer[$i],1,1) == "1" ||
- substring($buffer[$i],1,1) == "2" ||
- substring($buffer[$i],1,1) == "3" ||
- substring($buffer[$i],1,1) == "4" ||
- substring($buffer[$i],1,1) == "5" ||
- substring($buffer[$i],1,1) == "6" ||
- substring($buffer[$i],1,1) == "7" ||
- substring($buffer[$i],1,1) == "8" ||
- substring($buffer[$i],1,1) == "9" ||
- substring($buffer[$i],1,1) == "0" ||
- substring($buffer[$i],1,1) == "#"
- ) {
- // It is numerical, we are assuming that this is the frame number.
- $i = $numTokens;
- } else {
- $imageName = $imageName + "." + $buffer[$i];
- }
- ++$i;
- }
- }
- string $fullPath = getPfxImageLocation($imageName + "." + $ext);
-
- // Truncate the extension.
- $fullPath = `substitute ("." + $ext) $fullPath ""`;
- string $files;
- string $fileList[] = `getFileList -fld $fullPath -fs "*.*"`;
- $numTokens = size($fileList);
-
- if ( `about -nt` ) {
- $fullPath = unconvert( $fullPath );
- $fullPath = `substitute $imageName $fullPath ""`;
- }
-
- // Iterate on $fileList and copy them to $brushImagePath.
-
- if ($numTokens == 0 || ($numTokens == 1 && $fileList[0] == "unknown")) {
- warning("Cannot find source images for animated file texture to copy to the preset brush images directory.");
- } else {
- string $file;
- for ( $file in $fileList ) {
- string $filePath[];
- int $index = tokenize( $file, "/", $filePath );
- string $fullFileName = $fullPath + $filePath[$index-1];
- if ( `about -nt` ) {
- // Do not copy the file if it is already there.
- string $result = getPfxImageLocation($brushImagePath + "\\" + $filePath[$index-1]);
- if ($result == "unknown" || $result != ($tbip + $filePath[$index-1])) {
- sysFile -copy $brushImagePath $fullFileName;
- $file = unconvert( $file );
- print ( "Copying image texture file " + $file + " to " + $tbip );
- }
- }
- else if (`about -irix` || `about -linux` || `about -mac`) {
- string $result = getPfxImageLocation($brushImagePath + $filePath[$index-1]);
- if ($result == "unknown" || $result != ($brushImagePath + $filePath[$index-1])) {
- print ( "Copying image texture file " + $file + " to " + $brushImagePath );
- sysFile -copy $brushImagePath $file;
- }
- } else {
- warning("Unknown and unimplemented operating system in saveBrushToShelf.mel");
- }
- }
- }
- } else { // NOT if ($useFrameExt)
- // The name of the file is literal.
- string $fullPath = getPfxImageLocation( $imageName );
- if ($fullPath != "unknown") {
- if ( `about -nt` ) {
- string $mfullPath = makeNTPath( $fullPath );
- string $result = getPfxImageLocation ($brushImagePath + "\\" + $imageName);
- if ( $result == "unknown" || $result != ($tbip + $imageName)) {
- print ( "Copying image texture file " + $fullPath + " to " + $tbip );
- sysFile -copy $brushImagePath $mfullPath;
- }
- }
- else if (`about -irix` || `about -linux` || `about -mac`) {
- string $result = getPfxImageLocation($brushImagePath + $imageName);
- if ($result == "unknown" || $result != ($brushImagePath + $imageName)) {
- print ( "Copying image texture file " + $fullPath + " to " + $brushImagePath );
- sysFile -copy $brushImagePath $fullPath;
- }
- } else {
- warning("Unknown and unimplemented operating system in saveBrushToShelf.mel");
- }
- }
- } // end of else portion of if ($useFrameExt)
- } // end of $imageName != ""
-
- if ( $leafImage != "" ) {
- string $buffer[];
- $numTokens = `tokenize $leafImage "/" $buffer`;
- $leafImage = $buffer[$numTokens-1];
-
- string $fullPath = getPfxImageLocation($leafImage);
- if ($fullPath != "unknown") {
- if ( `about -nt` ) {
- string $mfullPath = makeNTPath( $fullPath );
- string $result = getPfxImageLocation($brushImagePath + "\\" + $leafImage);
- if ( $result == "unknown" || $result != ($tbip + $leafImage)) {
- sysFile -copy $brushImagePath $mfullPath;
- print ( "Copying leaf image texture file " + $fullPath + " to " + $tbip );
- }
- }
- else if (`about -irix` || `about -linux`) {
- string $result = getPfxImageLocation($brushImagePath + $leafImage);
- if ( $result == "unknown" || $result != ($brushImagePath + $leafImage)) {
- print ( "Copying leaf image texture file " + $fullPath + " to " + $brushImagePath );
- sysFile -copy $brushImagePath $fullPath;
- }
- } else if(`about -mac`) {
- string $result = getPfxImageLocation($brushImagePath + $leafImage);
- if ( $result == "unknown" || $result != ($brushImagePath + $leafImage)) {
- print ( "Copying leaf image texture file " + $fullPath + " to " + $brushImagePath );
- sysFile -copy $brushImagePath $fullPath;
- }
- } else {
- warning("Unknown and unimplemented operating system in saveBrushToShelf.mel");
- }
- }
- } // end $leafImage != ""
-
- if ( $flowerImage != "" ) {
- // We should really only try to copy the image file if "Flower Use Branch Texture" is off, but...
- string $buffer[];
- $numTokens = `tokenize $flowerImage "/" $buffer`;
- $flowerImage = $buffer[$numTokens-1];
-
- string $fullPath = getPfxImageLocation( $flowerImage );
- if ($fullPath != "unknown") {
- if ( `about -nt` ) {
- string $mfullPath = makeNTPath( $fullPath );
- string $result = getPfxImageLocation ($brushImagePath + "\\" + $flowerImage);
- if ( $result == "unknown" || $result != ($tbip + $flowerImage)) {
- sysFile -copy $brushImagePath $mfullPath;
- print ( "Copying flower image texture file " + $fullPath + " to " + $tbip );
- }
- }
- else if (`about -irix` || `about -linux`) {
- string $result = getPfxImageLocation ($brushImagePath + $flowerImage);
- if ( $result == "unknown" || $result != ($brushImagePath + $flowerImage)) {
- print ( "Copying flower image texture file " + $fullPath + " to " + $brushImagePath );
- sysFile -copy $brushImagePath $fullPath;
- }
- } else if (`about -mac`) {
- string $result = getPfxImageLocation ($brushImagePath + $flowerImage);
- if ( $result == "unknown" || $result != ($brushImagePath + $flowerImage)) {
- print ( "Copying flower image texture file " + $fullPath + " to " + $brushImagePath );
- sysFile -copy $brushImagePath $fullPath;
- }
- } else {
- warning("Unknown and unimplemented operating system in saveBrushToShelf.mel");
- }
- }
- } // end $flowerImage != ""
- }
-
- //
- // save the last used Visor Directory.
- //
- $gLastPresetDir = $gVisorSelectedDirectory;
-
- $gSelectDir = 0;
- window -e -visible false brushPresetWin;
- dynPaintEditor -edit -iconGrab false dynPaintScriptedPanelEd;
- }
-
- global proc updateBrushPresetWin()
- {
- // IF YOU ARE CHANGING THE NAMES OF THESE VARIABLES YOU
- // MUST ALSO CHANGE THEIR NAMES IN OTHER MEL FILES WHERE THEY
- // ARE REFERENCED! (ie. setPresetTmpIcon.mel) APP 17mar99
- global int $gBrushCount;
- global string $gTmpPaintPresetShelveButton;
- global string $gTmpPaintPresetLabelField;
- global string $gTmpPaintPresetOverlayField;
- global int $gBrushPresetWinUpdateJob;
- global string $gTmpVisorDirField;
-
- if( !`window -exists brushPresetWin` )
- {
- return;
- }
-
- string $brushName = `getDefaultBrush`;
- string $userName;
-
- if( $brushName == "defaultBrush" )
- {
- $userName = "brush" + $gBrushCount;
- }
- else
- {
- $userName = $brushName;
- }
- textFieldGrp -e -text $userName $gTmpPaintPresetLabelField;
- textFieldGrp -e -text $userName $gTmpPaintPresetOverlayField;
- shelfButton -e -i1 "userPaint.xpm" $gTmpPaintPresetShelveButton;
- }
-
- global proc prepareIconGrab (string $editor)
- {
- print ("// Click and drag in the Paint Effects window to grab the icon //");
- dynPaintEditor -edit -iconGrab true $editor;
- }
-
- global proc int visorDirSelCB( string $filename,
- string $fileType )
- {
- // Visor Directory selection callback function.
- global string $gVisorSelectedDirectory;
- global string $gTmpVisorDirField;
- global int $gSelectDir;
-
- $gVisorSelectedDirectory = $filename;
- textFieldGrp -e -text $gVisorSelectedDirectory $gTmpVisorDirField;
- $gSelectDir = 1;
-
- return true;
- }
-
- global proc openVisorFileBrowser()
- {
- global string $gLastPresetDir;
-
- if(!`file -q -ex $gLastPresetDir`)
- {
- sysFile -makeDir $gLastPresetDir;
- }
-
- workspace -dir $gLastPresetDir;
- fileBrowser "visorDirSelCB" "Save Brush Preset" "" 4;
- }
-
- global proc saveBrushToShelf()
- {
- global string $gTmpPaintPresetShelveButton;
- global string $gTmpPaintPresetLabelField;
- global string $gTmpPaintPresetOverlayField;
- global int $gBrushPresetWinUpdateJob;
- global string $gSaveBrushToShelf;
- global string $gTmpVisorDirField;
-
- global string $gVisorDirSelector;
- global string $gVisorSelectedDirectory = "";
- global int $gSelectDir = 0;
-
- //
- // $gLastPresetDir remembers the last directory used for saving the Brush Preset.
- //
- global string $gLastPresetDir = "";
-
-
- if($gLastPresetDir == "")
- {
- $gLastPresetDir = `internalVar -userPrefDir` + "brushes/";
- }
-
- if( !`window -exists brushPresetWin` )
- {
- int $textFieldWidth;
- window -t "Save Brush Preset" -w 410 -h 380 brushPresetWin;
- formLayout fl;
- columnLayout -adj true col1;
- formLayout -nd 100 psForm;
- $gTmpPaintPresetLabelField =
- `textFieldGrp -label "Label:" tfg2`;
- $gTmpPaintPresetOverlayField =
- `textFieldGrp -label "Overlay Label:" tfg3`;
-
- $gTmpPaintPresetShelveButton = `shelfButton shButTmp`;
- shelfButton -e -st "iconAndTextHorizontal"
- $gTmpPaintPresetShelveButton;
-
- button -label "Grab Icon" -c "prepareIconGrab dynPaintScriptedPanelEd" gbBut;
-
- $gSaveBrushToShelf = `radioButtonGrp -numberOfRadioButtons 2 -label "Save Preset:"
- -labelArray2 "To Shelf" "To Visor" -sl 1 sbts`;
-
- $gTmpVisorDirField =
- `textFieldGrp -label "Visor Directory:" -ed 0 tfg4`;
-
- $textFieldWidth = `textFieldGrp -q -width $gTmpVisorDirField`;
-
- if($textFieldWidth <= 0)
- {
- // On Irix, the width is returned to be zero, but on other platforms
- // it is returning 380, so the default value of 380 is assigned.
-
- $textFieldWidth = 380;
- }
-
- $gVisorDirSelector = `symbolButton -c "openVisorFileBrowser" -i "navButtonBrowse.xpm" -en false tfg5`;
-
- radioButtonGrp -e -on2 "textFieldGrp -e -ed 1 $gTmpVisorDirField;symbolButton -e -en true $gVisorDirSelector" $gSaveBrushToShelf;
- radioButtonGrp -e -of2 "textFieldGrp -e -ed 0 $gTmpVisorDirField;symbolButton -e -en false $gVisorDirSelector" $gSaveBrushToShelf;
-
- formLayout -e
- -af tfg2 right 0
- -af tfg2 left 0
- -af tfg2 top 7
- -an tfg2 bottom
-
- -af tfg3 right 0
- -af tfg3 left 0
- -ac tfg3 top 7 tfg2
- -an tfg3 bottom
-
- -af sbts left 0
- -af sbts right 0
- -ac sbts top 12 tfg3
- -an sbts bottom
-
- -af tfg4 left 0
- -af tfg4 right 0
- -ac tfg4 top 2 sbts
- -an tfg4 bottom
-
- -aof shButTmp right -95
- -an shButTmp left
- -ac shButTmp top 2 tfg4
- -af shButTmp bottom 2
-
- -af gbBut left 140
- -an gbBut right
- -ac gbBut top 4 tfg4
- -an gbBut bottom
-
- -af tfg5 left $textFieldWidth
- -an tfg4 right
- -ac tfg5 top 2 sbts
- -an tfg5 bottom
-
-
- psForm;
-
- setParent fl;
- separator -horizontal true shelfSeparator;
- button
- -label "Save Brush Preset"
- -c "saveBrushPreset; dynPaintEditor -edit -iconGrab false dynPaintScriptedPanelEd"
- saveBrushPresetButton;
- button
- -label "Close"
- -c "window -e -visible false brushPresetWin; dynPaintEditor -edit -iconGrab false dynPaintScriptedPanelEd"
- closeBrushPresetEdButton;
- formLayout -e
- -af shelfSeparator "left" 0
- -af shelfSeparator "right" 0
- -ac shelfSeparator "bottom" 5 closeBrushPresetEdButton
-
- -af saveBrushPresetButton "left" 5
- -af saveBrushPresetButton "bottom" 5
- -ap saveBrushPresetButton "right" 3 50
- -an saveBrushPresetButton "top"
-
- -ap closeBrushPresetEdButton "left" 2 50
- -af closeBrushPresetEdButton "bottom" 5
- -af closeBrushPresetEdButton "right" 5
- -an closeBrushPresetEdButton "top"
- fl;
- }
- updateBrushPresetWin();
- showWindow brushPresetWin;
- $gBrushPresetWinUpdateJob = `scriptJob -e SelectionChanged "brushPresetWinCallback"`;
-
- }
-
- global proc brushPresetWinCallback()
- {
- global int $gBrushPresetWinUpdateJob;
- if( !`window -exists brushPresetWin`
- || !`window -q -visible brushPresetWin` )
- {
- dynPaintEditor -edit -iconGrab false dynPaintScriptedPanelEd;
- evalDeferred ("scriptJob -kill " +$gBrushPresetWinUpdateJob);
- return;
- }
- updateBrushPresetWin();
- }
-